\(\int \frac {\tan ^2(x)}{a+a \cos (x)} \, dx\) [3]

   Optimal result
   Rubi [A] (verified)
   Mathematica [B] (verified)
   Maple [C] (verified)
   Fricas [B] (verification not implemented)
   Sympy [F]
   Maxima [B] (verification not implemented)
   Giac [B] (verification not implemented)
   Mupad [B] (verification not implemented)

Optimal result

Integrand size = 13, antiderivative size = 15 \[ \int \frac {\tan ^2(x)}{a+a \cos (x)} \, dx=-\frac {\text {arctanh}(\sin (x))}{a}+\frac {\tan (x)}{a} \]

[Out]

-arctanh(sin(x))/a+tan(x)/a

Rubi [A] (verified)

Time = 0.06 (sec) , antiderivative size = 15, normalized size of antiderivative = 1.00, number of steps used = 4, number of rules used = 4, \(\frac {\text {number of rules}}{\text {integrand size}}\) = 0.308, Rules used = {2785, 3852, 8, 3855} \[ \int \frac {\tan ^2(x)}{a+a \cos (x)} \, dx=\frac {\tan (x)}{a}-\frac {\text {arctanh}(\sin (x))}{a} \]

[In]

Int[Tan[x]^2/(a + a*Cos[x]),x]

[Out]

-(ArcTanh[Sin[x]]/a) + Tan[x]/a

Rule 8

Int[a_, x_Symbol] :> Simp[a*x, x] /; FreeQ[a, x]

Rule 2785

Int[((g_.)*tan[(e_.) + (f_.)*(x_)])^(p_.)/((a_) + (b_.)*sin[(e_.) + (f_.)*(x_)]), x_Symbol] :> Dist[1/a, Int[S
ec[e + f*x]^2*(g*Tan[e + f*x])^p, x], x] - Dist[1/(b*g), Int[Sec[e + f*x]*(g*Tan[e + f*x])^(p + 1), x], x] /;
FreeQ[{a, b, e, f, g, p}, x] && EqQ[a^2 - b^2, 0] && NeQ[p, -1]

Rule 3852

Int[csc[(c_.) + (d_.)*(x_)]^(n_), x_Symbol] :> Dist[-d^(-1), Subst[Int[ExpandIntegrand[(1 + x^2)^(n/2 - 1), x]
, x], x, Cot[c + d*x]], x] /; FreeQ[{c, d}, x] && IGtQ[n/2, 0]

Rule 3855

Int[csc[(c_.) + (d_.)*(x_)], x_Symbol] :> Simp[-ArcTanh[Cos[c + d*x]]/d, x] /; FreeQ[{c, d}, x]

Rubi steps \begin{align*} \text {integral}& = -\frac {\int \sec (x) \, dx}{a}+\frac {\int \sec ^2(x) \, dx}{a} \\ & = -\frac {\text {arctanh}(\sin (x))}{a}-\frac {\text {Subst}(\int 1 \, dx,x,-\tan (x))}{a} \\ & = -\frac {\text {arctanh}(\sin (x))}{a}+\frac {\tan (x)}{a} \\ \end{align*}

Mathematica [B] (verified)

Leaf count is larger than twice the leaf count of optimal. \(39\) vs. \(2(15)=30\).

Time = 0.13 (sec) , antiderivative size = 39, normalized size of antiderivative = 2.60 \[ \int \frac {\tan ^2(x)}{a+a \cos (x)} \, dx=\frac {\log \left (\cos \left (\frac {x}{2}\right )-\sin \left (\frac {x}{2}\right )\right )-\log \left (\cos \left (\frac {x}{2}\right )+\sin \left (\frac {x}{2}\right )\right )+\tan (x)}{a} \]

[In]

Integrate[Tan[x]^2/(a + a*Cos[x]),x]

[Out]

(Log[Cos[x/2] - Sin[x/2]] - Log[Cos[x/2] + Sin[x/2]] + Tan[x])/a

Maple [C] (verified)

Result contains complex when optimal does not.

Time = 0.51 (sec) , antiderivative size = 44, normalized size of antiderivative = 2.93

method result size
risch \(\frac {2 i}{a \left ({\mathrm e}^{2 i x}+1\right )}-\frac {\ln \left ({\mathrm e}^{i x}+i\right )}{a}+\frac {\ln \left ({\mathrm e}^{i x}-i\right )}{a}\) \(44\)
default \(\frac {-\frac {1}{\tan \left (\frac {x}{2}\right )+1}-\ln \left (\tan \left (\frac {x}{2}\right )+1\right )-\frac {1}{\tan \left (\frac {x}{2}\right )-1}+\ln \left (\tan \left (\frac {x}{2}\right )-1\right )}{a}\) \(45\)

[In]

int(tan(x)^2/(a+cos(x)*a),x,method=_RETURNVERBOSE)

[Out]

2*I/a/(exp(2*I*x)+1)-1/a*ln(exp(I*x)+I)+1/a*ln(exp(I*x)-I)

Fricas [B] (verification not implemented)

Leaf count of result is larger than twice the leaf count of optimal. 33 vs. \(2 (15) = 30\).

Time = 0.33 (sec) , antiderivative size = 33, normalized size of antiderivative = 2.20 \[ \int \frac {\tan ^2(x)}{a+a \cos (x)} \, dx=-\frac {\cos \left (x\right ) \log \left (\sin \left (x\right ) + 1\right ) - \cos \left (x\right ) \log \left (-\sin \left (x\right ) + 1\right ) - 2 \, \sin \left (x\right )}{2 \, a \cos \left (x\right )} \]

[In]

integrate(tan(x)^2/(a+a*cos(x)),x, algorithm="fricas")

[Out]

-1/2*(cos(x)*log(sin(x) + 1) - cos(x)*log(-sin(x) + 1) - 2*sin(x))/(a*cos(x))

Sympy [F]

\[ \int \frac {\tan ^2(x)}{a+a \cos (x)} \, dx=\frac {\int \frac {\tan ^{2}{\left (x \right )}}{\cos {\left (x \right )} + 1}\, dx}{a} \]

[In]

integrate(tan(x)**2/(a+a*cos(x)),x)

[Out]

Integral(tan(x)**2/(cos(x) + 1), x)/a

Maxima [B] (verification not implemented)

Leaf count of result is larger than twice the leaf count of optimal. 61 vs. \(2 (15) = 30\).

Time = 0.21 (sec) , antiderivative size = 61, normalized size of antiderivative = 4.07 \[ \int \frac {\tan ^2(x)}{a+a \cos (x)} \, dx=-\frac {\log \left (\frac {\sin \left (x\right )}{\cos \left (x\right ) + 1} + 1\right )}{a} + \frac {\log \left (\frac {\sin \left (x\right )}{\cos \left (x\right ) + 1} - 1\right )}{a} + \frac {2 \, \sin \left (x\right )}{{\left (a - \frac {a \sin \left (x\right )^{2}}{{\left (\cos \left (x\right ) + 1\right )}^{2}}\right )} {\left (\cos \left (x\right ) + 1\right )}} \]

[In]

integrate(tan(x)^2/(a+a*cos(x)),x, algorithm="maxima")

[Out]

-log(sin(x)/(cos(x) + 1) + 1)/a + log(sin(x)/(cos(x) + 1) - 1)/a + 2*sin(x)/((a - a*sin(x)^2/(cos(x) + 1)^2)*(
cos(x) + 1))

Giac [B] (verification not implemented)

Leaf count of result is larger than twice the leaf count of optimal. 45 vs. \(2 (15) = 30\).

Time = 0.33 (sec) , antiderivative size = 45, normalized size of antiderivative = 3.00 \[ \int \frac {\tan ^2(x)}{a+a \cos (x)} \, dx=-\frac {\log \left ({\left | \tan \left (\frac {1}{2} \, x\right ) + 1 \right |}\right )}{a} + \frac {\log \left ({\left | \tan \left (\frac {1}{2} \, x\right ) - 1 \right |}\right )}{a} - \frac {2 \, \tan \left (\frac {1}{2} \, x\right )}{{\left (\tan \left (\frac {1}{2} \, x\right )^{2} - 1\right )} a} \]

[In]

integrate(tan(x)^2/(a+a*cos(x)),x, algorithm="giac")

[Out]

-log(abs(tan(1/2*x) + 1))/a + log(abs(tan(1/2*x) - 1))/a - 2*tan(1/2*x)/((tan(1/2*x)^2 - 1)*a)

Mupad [B] (verification not implemented)

Time = 13.53 (sec) , antiderivative size = 30, normalized size of antiderivative = 2.00 \[ \int \frac {\tan ^2(x)}{a+a \cos (x)} \, dx=-\frac {2\,\mathrm {atanh}\left (\mathrm {tan}\left (\frac {x}{2}\right )\right )}{a}-\frac {2\,\mathrm {tan}\left (\frac {x}{2}\right )}{a\,\left ({\mathrm {tan}\left (\frac {x}{2}\right )}^2-1\right )} \]

[In]

int(tan(x)^2/(a + a*cos(x)),x)

[Out]

- (2*atanh(tan(x/2)))/a - (2*tan(x/2))/(a*(tan(x/2)^2 - 1))